<?php
/**
 * Created by PhpStorm.
 * User: meng
 * Date: 2021/7/8
 * Time: 10:11 上午
 */

namespace app\admin\validator;


use app\lib\BaseValidator;

class AdminRoleValidator extends BaseValidator
{
    protected $rule = [
        'id'       => 'require|isPostInt',
        'name'     => 'require|alphaDash|length:2,50',
        'remarks'  => 'length:1,200',
        'user_id'  => 'require|isPostInt',
        'user_ids' => 'require|array|min:1',
        'menu_ids' => 'array'
    ];

    protected $message = [
        'id'       => 'id不正确',
        'name'     => '角色名称长度2-50字,只能为英文、数字、下划线及减号',
        'remarks'  => '备注不能超过200字',
        'user_id'  => '用户id不正确',
        'user_ids' => '请选择需要绑定的成员',
        'menu_ids' => '需要绑定的菜单只能为数组'
    ];

    protected $scene = [
        'create'     => ['name', 'remarks'],
        'update'     => ['id', 'name', 'remarks'],
        'member'     => ['id', 'user_id'],
        'bindMember' => ['id', 'user_ids'],
        'bindMenu'   => ['id', 'menu_ids']
    ];
}
